#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e5 + 5;

int n, m;
int a[N], c[N];
set<int> mx[335];
deque<int> blk[335];
int bs, bn;
void push_front(int id, int i) {
  mx[id].insert(a[i]);
  blk[id].push_front(i);
}
void push_back(int id, int i) {
  mx[id].insert(a[i]);
  blk[id].push_back(i);
}
int pop_front(int id) {
  int j = blk[id].front();
  blk[id].pop_front();
  mx[id].erase(a[j]);
  return j;
}
int pop_back(int id) {
  int j = blk[id].back();
  blk[id].pop_back();
  mx[id].erase(a[j]);
  return j;
}
int back(int id) { return blk[id].back(); }
int get_mx(int id) {
  if (mx[id].empty()) return 0;
  return *mx[id].rbegin();
}
int size(int id) { return blk[id].size(); }

void solve() {
  cin >> n;
  rep(i, 1, n) cin >> a[i] >> c[i];
  bs = sqrt(n * log2(n));
  rep(i, 1, n) {
    int cnt = c[i];
    int id = bn;
    while (id && get_mx(id) < a[i] && size(id) <= cnt) {
      cnt -= size(id);
      id--;
    }
    if (!id) {
      id = 1;
      push_front(id, i);
    } else {
      stack<int> tmp;
      while (size(id) && a[back(id)] < a[i] && cnt) {
        cnt--;
        tmp.push(blk[id].back());  // without adjusting set
        blk[id].pop_back();
      }
      push_back(id, i);
      while (tmp.size()) {
        blk[id].push_back(tmp.top());
        tmp.pop();
      }
    }
    rep(i, id, bn) {
      if (size(i) > bs) {
        push_front(i + 1, pop_back(i));
      }
    }
    if (size(bn + 1)) bn++;
  }
  rep(i, 1, bn) {
    while (size(i)) {
      cout << pop_front(i) << ' ';
    }
  }
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}